package com.anhry.www.safety.manage.system.struts.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.anhry.www.safety.manage.enterprise.bean.TbCorpInfo;
import com.anhry.www.safety.manage.system.struts.base.SystemBaseAction;
import com.anhry.www.safety.util.Loggers;
import com.anhry.www.safety.util.Util;
import com.anhry.www.safety.util.bean.UtilBean;

/**
 * @date:Aug 20, 2012
 * @remark:
 * @author:dongbin
 */

@Controller
@Scope("prototype")
public class IndexAction extends SystemBaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List msgList;
	private UtilBean bean; 

	public String execute() {
		try {
			TbCorpInfo corp = (TbCorpInfo)this.contextPvd.getSessionAttr(Util.SESSION_CORPUSER);
			this.setMsgList((List)this.utilService.getHqlQuery("from TbCorpMsg t where 1=1 and t.msgType=0 and t.isClock=0 order by t.msgDate desc",0,6));//公告通知
			UtilBean b = new UtilBean();
			b.setStr1(this.utilService.getObjectBySql("select count(*) from tb_oa_call_msg_view t where t.is_read=0 and t.adds_corp="+corp.getId()));
			b.setStr2(this.utilService.getObjectBySql("select count(*) from tb_oa_notice_user t where t.is_read=0 and t.corp_id="+corp.getId()));
			this.setBean(b);
		} catch (Exception e) {
			e.printStackTrace();
			Loggers.info("IndexAction类中execute()方法：" + e.getMessage());
		}

		return SUCCESS;
	}

	public List getMsgList() {
		return msgList;
	}

	public void setMsgList(List msgList) {
		this.msgList = msgList;
	}

	public UtilBean getBean() {
		return bean;
	}

	public void setBean(UtilBean bean) {
		this.bean = bean;
	}
	
	
}
